﻿using System;

namespace CNG
{
    internal static class Utils
    {
        public static void Require<Ex>(this bool Condition, string Message) where Ex : Exception
        {
            if (Condition)
                throw (Ex)Activator.CreateInstance(typeof(Ex), Message);
        }

        internal static int CountNonZeroBytes(this byte[] arr)
        {
            int z = 0;
            for (int i = 0; i < arr.Length; i++)
                if (arr[i] == 0) z++;
            return arr.Length - z;
        }
    }
}
